<?php
/**
 * 该函数只返回检验报告的查询结果
 * Created by PhpStorm.
 * User: zhang-hong
 * Date: 2017/3/9
 * Time: 10:50
 */
class GetjianyanresultController extends Yaf_Controller_Abstract
{
    function IndexAction()
    {
        //获取数据
        $request = $this->getRequest();
        $jiancha_id = $request->getPost("jiancha_id",0);
        $yiyuan_id = $request->getPost("yiyuan_id",0);
        $lisJianchaInfoModel = new LisJianChaInfoModel();
        if(!ctype_digit("$yiyuan_id"))
        {
            Utility::apiJsonError(20027, '医院ID必须是整型');
        }
        if(!ctype_digit("$jiancha_id") )
        {
            Utility::apiJsonError(20016, '检查ID必须是整型');
        }

        $list_jiancha_result = $lisJianchaInfoModel->getJianchaInfoById($jiancha_id,$yiyuan_id);
        $data['result'] = array();
        foreach($list_jiancha_result as $key => $one)
        {
            foreach($one as $k=>$v){
                if(empty($v) && $v == null){
                    $data['result'][$key][$k] = "";
                }else{
                    $data['result'][$key][$k] = $v;
                }
            }
            if(!empty($one['jiancha_result']) and is_numeric($one['jiancha_result']) and ((!empty($one['cankaozhi_dingliang_up']) and is_numeric($one['cankaozhi_dingliang_up'])) or (!empty($one['cankaozhi_dingliang_dowm']) and is_numeric($one['cankaozhi_dingliang_dowm']))))
            {
                if($one['jiancha_result'] < $one['cankaozhi_dingliang_dowm'])
                {
                    $data['result'][$key]['yichang_tag'] = "↓";
                }
                else if($one['jiancha_result'] > $one['cankaozhi_dingliang_up'])
                {
                    $data['result'][$key]['yichang_tag'] = "↑";
                }
                else
                {
                    $data['result'][$key]['yichang_tag'] = "";
                }
            }
            else
            {
                $data['result'][$key]['yichang_tag'] = "";
            }
        }
        if(!empty($data['result']))
        {
            $data['state'] = '1';
        }
        else
        {
            $data['state'] = '0';
        }
        $data["msg"] = "";
        $data["error"] = 200;
        Utility::apiJsonResultExtends($data);
        // 是否进行数据压缩
        //$compressed = $_REQUEST["compression_http_data"];
        //Utility::apiJsonResult($data,"",$compressed);
    }
}